﻿using UnityEngine;
using System.Collections;

public class EnemyIcon : MonoBehaviour {

    private Transform icon;

    private Transform player;
	// Use this for initialization
	void Start () {

        if (this.tag == Tags.boss)
        {
            icon = MinimapBg._instance.GetBossIcon().GetComponent<Transform>();
            
        }
        else
            if (this.tag == Tags.monst)
            {
                icon=MinimapBg._instance.GetMonstIcon().GetComponent<Transform>();
            }

       
        player=GameObject.FindGameObjectWithTag(Tags.player).GetComponent<Transform>();
	}
	
	// Update is called once per frame
	void Update () {
        Vector3 offset=new Vector3(0,0,0);
        if (player)
        {
            offset = transform.position - player.position;
        }
        offset *= 5;
        icon.localPosition = new Vector3(offset.x, offset.z, 0);
	}

    // 系统方法
    void OnDestroy()
    {
        if (icon != null)
        {
            Destroy(icon.gameObject);
        }
    }
}
